﻿using BCCServer.DAO.Interfaces;
using BCCServer.Model.Models;
using BCCServer.Model.ModelsOut;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace BCCServer.DAO.user
{
    public class userDB : IuserDB
    {
        //protected static bccContext context = new Model.Models.bccContext();

        private readonly bccContext _context;

        public userDB(bccContext Context)
        {
            this._context = Context;
        }

        /// <summary>
        /// 根据账号查询用户信息
        /// </summary>
        /// <param name="Account"></param>
        /// <returns></returns>
        public BCCUserOut selUserInfo(string Account)
        {
            var bccUser = _context.UUsers.Where(i => i.Account == Account).AsEnumerable().Select(item => new BCCUserOut
            {
                Id = item.Id,
                Account = item.Account,
                UserName = item.UserName,
                UserSign = item.UserSign,
                Address = item.Address,
                Telephone = item.Telephone,
                Mail = item.Mail,
                RoleId = item.RoleId
            }).FirstOrDefault();

            return bccUser;
        }
    }
}
